<?php
// L'objet user, démarrage de la session utilisateur
$userData = $user->getUserData();
?>
<script type="text/javascript">
    $(document).ready(function() {
        var courriel = new LiveValidation('courriel');
		courriel.add( Validate.Presence );
		courriel.add( Validate.Email );

        var mliberty = new LiveValidation('mliberty');
		mliberty.add( Validate.Presence );
		mliberty.add( Validate.Length, { minimum: 7 } );

        var mpaypal = new LiveValidation('mpaypal');
		mpaypal.add( Validate.Presence );
		mpaypal.add( Validate.Email );

        var mont1 = new LiveValidation('mont1');
		mont1.add( Validate.Presence );
		mont1.add( Validate.Numericality, { minimum: <?php echo "$mini_service_4"; ?>, maximum: <?php echo "$max_service_4"; ?> } );
		mont1.add( Validate.Numericality, { maximum: <?php echo "$dispo_service_1"; ?> } );

		var mont2 = new LiveValidation('mont2');
		mont2.add( Validate.Presence );
		var mont2_ter = new LiveValidation('mont2_ter');
		mont2_ter.add( Validate.Presence );
		//mont2.add( Validate.Numericality, { maximum: <?php echo "$dispo_service_1"; ?> } );

        var termes = new LiveValidation('termes');
		termes.add( Validate.Acceptance );

        var currentMont1 = 0;
        $("#mont1").everyTime(200, function() {
            if ($(this).val() != currentMont1) {
                var montant = $(this).val();
                $(this).val(montant.replace(/,/g,"\."));
				var taxeF1 = ( <?php echo "$fraisV_eg";  ?>/(montant/100) );
				var taxeF2 = ( <?php echo "$fraisV_service_4";  ?>/(montant/100) );
				var taxeF3 = ( <?php echo "$fraisV_service_1";  ?>/(montant/100) );
				var taxeFixe = ( taxeF1 + taxeF2 + taxeF3 );
				var taxeV = ( <?php echo "$frais_eg";  ?> + <?php echo "$frais_service_4";  ?> + <?php echo "$frais_service_1";  ?> );
				var taxe = Math.round ((taxeFixe + taxeV)*1000)/1000;
                var mont2 = Math.round( (montant*(100-taxe)) ) / 100;
				
				var taux = Math.round ((<?php echo "$tauxUsdEur";  ?> - ( (<?php echo "$tauxUsdEur";  ?>/100) * <?php echo "$frais_eg";  ?> ))*10000)/10000;

				var mont2_ter = Math.round ((mont2*taux)*100)/100;
                $("#mont2").val(mont2);
				$("#taxe").val(taxe);
				$("#taux").val(taux);
				$("#mont2_ter").val(mont2_ter);
                currentMont1 = $("#mont1").val();
            }
        });
    });
</script>

<h3><span class='themecolor'>Etape 3/5, Remplissez le formulaire de Pr&eacute;Commande</span></h3>

<p> Notez que les champs pr&eacute;c&eacute;d&eacute;s d'une <span class="c1">*</span>
doivent obligatoirement &ecirc;tre remplis.Que les montants doivent comporter <b>les centimes, deux chiffres apr&eacute;s la virgule.</b>
Les Frais de gestion appliquer sont afficher dans le formulaire et sont variable selon le montant demander.</p>

<form id="form_brut" name="form_brut" method="post" action="./forms_lrppUE.php" onSubmit="return CheckInput();">
<div id="ae-content">
<?php
if (!empty($form_msg)) {
    echo '<div style="font-weight:center;"><span class="c1">';
    foreach ($form_msg as $m) :
        echo $m.'<br />';
    endforeach;
    echo '</span></div>';
}
?>
<fieldset id="InfoCom">
	<h2><span class='themecolor'>Vos Infos</span></h2>
	<div>
	<label><span class="legende_elmt">Votre Pseudo :</span></label>
	<span class="c2">*</span>
	<input id="pseudo" name="pseudo" class="cases" type="text" value="<?php echo $userData['pseudo']; ?>" maxlength="35" readonly="readonly"/>
	</div>
	<br />
	
	<div>
	<label><span class="legende_elmt">Votre Courriel de contact :</span></label>
	<span class="c2">*</span>
	<input id="courriel" name="email" class="cases" type="text" value="<?php echo $userData['email']; ?>" maxlength="35" readonly="readonly"/>
	</div>
	<br />
<h5><span class="c4">Information préremplis non modifiable</span></h5>
</fieldset>

<fieldset id="Compte">

	<h2><span class='themecolor'>Les comptes concern&eacute;</span></h2>
	
	<label><span class="legende_elmt">Votre compte <?php echo "$service_name_4"; ?> :</span></label>
	<span class="c2">*</span>
	<input id="mliberty" class="cases" type="text" maxlength="35" name="mliberty" value="<?php echo $mliberty; ?>"/>
	<br/>

	<label><span class="legende_elmt">Votre Courriel <?php echo "$service_name_1"; ?> :</span></label>
	<span class="c2">*</span>
	<input id="mpaypal" class="cases" type="text" maxlength="35" name="mpaypal" value="<?php echo $mpaypal; ?>"/>
	<br/>
</fieldset>

<fieldset id="montants">

	<h2><span class='themecolor'>Pour quels montant</span></h2><br />
	

	<label><span class="legende_elmt">Montant que vous d&eacute;sirez envoyer (Usd)</span></label>
	<span class="c2">*</span>
	<input id="mont1" class="cases" type="text" maxlength="6" name="mont1" value="<?php echo $mont1; ?>" /><br/>
	
	<label><span class="legende_elmt">Frais appliquer (%)</span></label>
	<span class="c2">*</span>
	<input id="taxe" class="cases" type="text" maxlength="6" name="taxe" onfocus="this.blur();" /><?php print "$taxe"; ?>
	<br/>
	
	<label><span class="legende_elmt">Montant &agrave; recevoir (Usd) avant le change</span></label>
	<span class="c2">*</span>
	<input id="mont2" class="cases" type="text" maxlength="6" name="mont2" onfocus="this.blur();" />
    <br />
	<label><span class="legende_elmt">Taux Dollars/Euros pour 1 dollar <?php echo "$taux";  ?>(Eur)</span></label>
	<span class="c2">*</span>
	<input id="taux" class="cases" type="text" maxlength="6" name="taux" onfocus="this.blur();" />
	<br/>
	
	<label><span class="legende_elmt">Montant &agrave; recevoir (Eur)</span></label>
	<span class="c2">*</span>
	<input id="mont2_ter" class="cases" type="text" maxlength="6" name="mont2_ter" onfocus="this.blur();" />
    <br />

    <label><span class="legende_elmt">Votre code PIN:</span></label>
	<span class="c2">*</span>
	<input id="pin" name="pin" class="cases" type="text" value="" maxlength="6" style="width:50px"/>
	<br />
</fieldset>
<p>J'ai lu les <a href="../reglements.php">Termes et les conditions d'utilisations et de ventes</a> EgainMoney <span class="c2">*</span><input id="termes" type="checkbox" name="termes" value="termes"/></p>

</div>
<div class="c3">
<input class="verif" type="submit" value="Suivant" name="envoi"/>
<input class="verif" type="reset" value="Recommencer"/>
<a href='../precom.php'><input type="reset" name="action" value="Annuler"/></a>

</div>
</form>

<p>
Le Montant Maximum par commande est de <span class="c1"><?php echo "$max_service_4"; ?></span> Dollars, et le Minimun de <span class="c1"><?php echo "$mini_service_4"; ?></span> Dollars.<br />
Le Montant Disponible sur notre compte <b><?php echo "$service_name_1"; ?></b> est de <span class="c1"><?php echo "$dispo_service_1"; ?></span> Euros.<br />
Le Montant du Plafond du jours est de <span class="c1"><?php echo "$plafond_jour_usd"; ?></span> Dollars, et nous en somme a <span class="c1"><?php echo "$montant_plafond_journee_usd"; ?></span> Dollars.</p>
